<%@ page import="com.mysql.cj.Session" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    if(session.getAttribute("signIn") != null)
        if(session.getAttribute("signIn").equals("true")){
            response.sendRedirect("notes.jsp");
            return;
        }

%>
<!DOCTYPE html>
<html>
<head>
    <title>Sign Up</title>
    <!-- 最新版本的 JQuery 文件 -->
    <script src="https://code.jquery.com/jquery-3.6.0.js"></script>

    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
          integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css"
          integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
            integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd"
            crossorigin="anonymous"></script>

    <!-- 用户名密码正则匹配及MD5加密 -->
    <script src="js/md5.js"></script>
    <script src="js/validation.js"></script>

    <style>
        .msg {
            visibility: hidden;
        }
    </style>
</head>
<body>
<h1>&nbsp;<div class="glyphicon glyphicon-ok-circle"></div>
    Sign Up &nbsp;
</h1>

<div class="col-md-4 col-sm-6 col-xs-12">
    <div class="alert alert-danger" role="alert" style="display: <%=session.getAttribute("duplicatedName") == "true" ? "block" : "none"%>"> <strong>Warning!</strong> Duplicated user name!</div>
    <%
        session.removeAttribute("duplicatedName");
    %>
    <form id="form" action="SignUp" method="post">
        <div class="form-group">
            <label for="uname">User&nbsp;Name</label>
            <input type="text" class="form-control" id="uname" name="uname" placeholder="User Name">
            <span class="msg">Need 3~15 characters mixed by letters,numbers or space.</span>
        </div>
        <div class="form-group">
            <label for="pwd">Password</label>
            <input type="password" class="form-control" id="pwd" name="pwd" placeholder="Password">
            <span class="msg">Need 8~16 characters mixed by letters and number.</span>
        </div>
        <button id="sub" class="btn btn-info glyphicon glyphicon-ok">&nbsp;Confirm</button>
    </form>
    <br>
    <div>Already have an account?
        <br>
        Click <a href="index.jsp">here</a> to sign in.
    </div>
</div>
</body>
</html>